//CustomClass Template - Created by CodenameGamma
//Replace Layout with the CC name, 
//and WoWClass.Mage with the Class your Designing for.
//Created July, 3rd 2010
//For use with Honorbuddy
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

namespace ArcanePower
{
    class Classname : CombatRoutine
    {
        public override sealed string Name { get { return "Arcane Power"; } }

        public override WoWClass Class { get { return WoWClass.Mage; } }


        private static LocalPlayer Me { get { return ObjectManager.Me; } }
 





        private void slog(string format, params object[] args) //use for slogging
        {
            Logging.Write(format, args);
        }

        public override bool WantButton
        {
            get
            {

                return true;
            }
        }

        #region Pull

        public override void Pull()
        {


        }


        #endregion

        public override void OnButtonPress()
        {
            //ConfigForm.ShowDialog();
        }


        #region Combat

        public override void Combat()
        {
            CastMeUpFlameOrb("FlameOrb");
            CastMeUpMirrorImages("MirrorImages");
            CastMeUpArcaneBlast("ArcaneBlast");
            while (Me.IsCasting)
            {
                Thread.Sleep(100);
            }


            if (SpellManager.CanCast("Evocation") && Me.ManaPercent < 68)
            {
                
                    UseManaGem();
                
                if (SpellManager.CanCast("Evocation") && Me.ManaPercent < 28)
                {
                    CastMeUpEvocation("Evocation");
                    if (SpellManager.CanCast("Arcane Missiles"))
                    {
                        CastMeUpArcaneMissiles("ArcaneMissiles");
                        while (Me.IsCasting)
                        {
                            Thread.Sleep(100);
                        }
                    }
                    else
                    {
                        CastMeUpArcaneBarrage("ArcaneBarrage");

                    }
                }
            }




            if (!SpellManager.CanCast("Evocation") && Me.Debuffs["Arcane Blast"].StackCount == 3 && Me.ManaPercent < 70)
                    {
                        if (SpellManager.CanCast("Arcane Missiles"))
                        {
                            CastMeUpArcaneMissiles("ArcaneMissiles");
                            while (Me.IsCasting)
                            {
                                Thread.Sleep(100);
                            }
                        }
                        else
                        {
                            CastMeUpArcaneBlast("ArcaneBlast");
                            while (Me.IsCasting)
                            {
                                Thread.Sleep(100);
                            }
                        }

                    
                }
                
        }

        #endregion
       
   
        #region Spells
         
               
           public void CastMeUpArcaneBlast(string ArcaneBlast)
        {
            if (SpellManager.CanCast("Arcane Blast"))
            {
                SpellManager.Cast("Arcane Blast");
            }

        }

           public void CastMeUpEvocation(string Evocation)
           {
               if (SpellManager.CanCast("Evocation"))
               {
                   SpellManager.Cast("Evocation");
               }

           }

           public void CastMeUpArcaneMissiles(string ArcaneMissiles)
           {
               if (SpellManager.CanCast("Arcane Missiles"))
               {
                   SpellManager.Cast("Arcane Missiles");
               }

           }


           public void CastMeUpArcaneBarrage(string ArcaneBarrage)
           {
               if (SpellManager.CanCast("Arcane Barrage"))
               {
                   SpellManager.Cast("Arcane Barrage");
               }

           }

           public void UseManaGem()
           {
               Lua.DoString("RunMacroText(\"/use item:" + 36799 + "\");");
           }

           public void CastMeUpFlameOrb(string FlameOrb)
           {
               if (SpellManager.CanCast("Flame Orb"))
               {
                   SpellManager.Cast("Flame Orb");
               }

           }

           public void CastMeUpMirrorImages(string MirrorImages)
           {
               if (SpellManager.CanCast("Mirror Image"))
               {
                   Lua.DoString("RunMacroText(\"/use item:" + "Soul Casket" + "\");");
                   SpellManager.Cast("Arcane Power");
                   SpellManager.Cast("Mirror Image");

               }

           }
        #endregion
    }   
}
